home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softdisk Supreme
/
Softdisk Supreme.iso
/
pc
/
DSK Files
/
0-49
/
SD020d.dsk
/
PIE CHART.bas
< prev
next >
Wrap
BASIC Source File
|
2003-06-12
|
9KB
|
232 lines
10 CLEAR : HOME : DIM L$(18): DIM V(18): DIM L1$(18): DIM V1(18): DIM LE$(4)
20 DIM PR(6):PR(1) = 1:PR(2) = 1:PR(3) = 1:PR(4) = 1:PR(5) = 1:PR(6) = 0: REM PARAMETERS
30 DEF FN X(C) = RA * SIN(C) +XC: DEF FN Y(C) = RA *.9 * COS(C) +YC
40 PI = 3.1415926:DL = 25056: REM CONSTANTS
50 VTAB 10: HTAB 15: PRINT "PIE CHART"
60 REM LEGEND READER
70 REM LEGENDS IN LE$(HF)
80 FOR HF = 2 TO 5
90 VF = -1: GOSUB 2500:LE$(HF -1) = W$
100 IF LEN(LE$(HF -1)) = 8 THEN 120
110 LE$(HF -1) = LE$(HF -1) +" ": GOTO 100: REM ONE SPACE
120 VF = 0: GOSUB 2500:LE$(HF -1) = LE$(HF -1) +W$
130 NEXT HF
140 REM OPTIONS I/O
150 TV = 0:LL = 0:NG = 0:CN = 0:NF = 0
160 HOME : HTAB 5: INVERSE : PRINT "SOFTGRAPH PIE CHART GENERATOR": NORMAL
170 POKE 32,7: VTAB 3
180 FOR HF = 1 TO 4: PRINT "LEGEND ";HF;": ";LE$(HF): NEXT HF
190 POKE 32,1: PRINT
200 PRINT "HOW MANY LABEL FIELDS (1 OR 2)?": PRINT : REM PR(1)
210 PRINT "CHART WHICH COLUMN (1 THROUGH 4)?": PRINT : REM PR(2)
220 PRINT "SORT: 0=DON'T; 1=VALUES; 2=LABELS:": PRINT : REM PR(3)
230 PRINT "COLOR: 0=NO; 1=YES:": PRINT : REM PR(4)
240 PRINT "STYLE: 0=SIDEWAYS; 1=UPRIGHT:": PRINT : REM PR(5)
250 PRINT "ROTATION: -180 TO 180:": PRINT : REM PR(6)
260 TEXT
270 FOR P = 1 TO 6: VTAB 6 +2 *P: HTAB 37: PRINT PR(P);: NEXT P
280 VTAB 20: HTAB 1: PRINT "ARROWS MOVE CURSOR": PRINT "SPACE SELECTS QUESTION": PRINT "CONTROL-P PROCESSES PIE CHART": PRINT "CONTROL-Q QUITS TO MENU"
290 P = 1
300 VTAB 6 +2 *P: HTAB 1: FLASH : PRINT ">";: NORMAL
310 HTAB 1: GET A$
320 A = ASC(A$)
330 IF A = 8 OR A = 21 THEN VTAB 6 +2 *P: HTAB 1: PRINT " ";: GOTO 380
340 IF A = 32 THEN 430
350 IF A = 17 THEN 2400
360 IF A = 16 THEN 550
370 GOTO 310
380 REM POINTER MOVE
390 P = P + SGN(A -10)
400 IF P = 0 THEN P = 6
410 IF P = 7 THEN P = 1
420 GOTO 300
430 REM GET NEW VALUE
440 VTAB 24: HTAB 1: INVERSE : PRINT "ENTER NEW VALUE: ";: NORMAL :W$ = ""
450 VTAB 24: HTAB 18: PRINT W$;
460 GET A$:A = ASC(A$)
470 IF A = 8 THEN 510
480 IF A = 13 THEN PR(P) = VAL(W$): VTAB 6 +2 *P: HTAB 37: PRINT PR(P);: CALL -868: VTAB 24: HTAB 1: CALL -868: GOTO 300
490 IF A <45 OR A >57 OR A = 46 OR A = 47 OR LEN(W$) = 4 THEN 450
500 W$ = W$ +A$: GOTO 450
510 IF LEN(W$) = 1 THEN W$ = "": PRINT CHR$(8);" ";
520 IF W$ = "" THEN 450
530 W$ = LEFT$(W$, LEN(W$) -1)
540 PRINT CHR$(8);" ";: GOTO 450
550 REM START PROCESSING
560 REM CHECK PARAMETERS
570 VTAB 6 +2 *P: HTAB 1: PRINT " ";
580 P = 1: IF PR(P) <1 OR PR(P) >2 THEN 650
590 P = 2: IF PR(P) <1 OR PR(P) >4 THEN 650
600 P = 3: IF PP(P) <0 OR PR(P) >2 THEN 650
610 P = 4: IF PR(P) <0 OR PR(P) >1 THEN 650
620 P = 5: IF PR(P) <0 OR PR(P) >1 THEN 650
630 P = 6: IF ABS(PR(P)) >180 THEN 650
640 GOTO 660
650 VTAB 6 +2 *P: HTAB 1: FLASH : PRINT ">"; CHR$(7);: NORMAL : VTAB 24: HTAB 1: PRINT "VALUE ILLEGAL";: GET A$: GOTO 310
660 REM READ LABELS
670 HOME : PRINT "READING LABELS": PRINT
680 FOR VF = 1 TO 18
690 HF = 1: GOSUB 2500:L$(VF) = W$
700 IF LEN(W$) = 0 THEN NF = VF -1:VF = 18: GOTO 750
710 IF PR(1) = 1 THEN 750
720 IF LEN(L$(VF)) = 8 THEN 740
730 L$(VF) = L$(VF) +" ": GOTO 720: REM ONE SPACE
740 HF = 2: GOSUB 2500:L$(VF) = L$(VF) +W$
750 HTAB 5: PRINT L$(VF): NEXT VF: IF NF = 0 THEN NF = 18
760 REM READ VALUES
770 PRINT "READING VALUES": PRINT
780 HF = PR(2) +1: FOR VF = 1 TO NF
790 GOSUB 2500
800 V(VF) = VAL(W$)
810 NEXT VF
820 LL = 0:GF = 1:NG = NF
830 FOR VF = 1 TO NF
840 IF V(VF) >0 THEN L1$(GF) = L$(VF):V1(GF) = V(VF): GOTO 880
850 PRINT "CANNOT GRAPH ";L$(VF);": ";V(VF)
860 SF = 1
870 NG = NG -1: GOTO 910
880 IF LEN(L$(VF)) >LL THEN LL = LEN(L$(VF))
890 HTAB 5: PRINT L$(VF);: HTAB 25: PRINT V(VF)
900 GF = GF +1
910 NEXT VF
920 PRINT : IF NG = 0 THEN PRINT "NO GRAPHABLE FIELDS FOUND": PRINT "HIT A KEY";: GET A$: GOTO 140
930 IF SF = 0 THEN 980
940 SF = 0: PRINT "OKAY TO CONTINUE? ";
950 GET A$: IF A$ < >"Y" AND A$ < >"N" THEN 950
960 IF A$ = "N" THEN 140
970 PRINT : PRINT
980 REM SORTING
990 IF PR(3) = 0 THEN 1130
1000 PRINT "SORTING"
1010 FOR VF = 1 TO NG
1020 CF = 1
1030 FOR GF = 2 TO NG
1040 ON PR(3) GOTO 1070,1050
1050 IF L1$(GF) <L1$(CF) THEN CF = GF
1060 GOTO 1080
1070 IF V1(GF) >V1(CF) THEN CF = GF
1080 NEXT GF
1090 L$(VF) = L1$(CF):V(VF) = V1(CF):L1$(CF) = CHR$(95):V1(CF) = 0
1100 TV = TV +V(VF)
1110 NEXT VF
1120 GOTO 1180
1130 REM COPY DATA
1140 FOR VF = 1 TO NG
1150 L$(VF) = L1$(VF):V(VF) = V1(VF)
1160 TV = TV +V(VF)
1170 NEXT VF
1180 IF PR(3) = 0 THEN 1230
1190 PRINT : FOR VF = 1 TO NG
1200 HTAB 5
1210 PRINT L$(VF); TAB( 25);V(VF)
1220 NEXT : PRINT
1230 PRINT "LEGEND: ";LE$(PR(2))
1240 PRINT : PRINT "LONGEST LABEL IS ";LL;" CHARACTERS"
1250 PRINT "TOTAL OF ALL VALUES IS ";TV
1260 PRINT : PRINT "FORMATTING CHART"
1270 REM FORMAT CHART
1280 D = 1:F = 2: IF PR(5) = 0 THEN D = 4
1290 CO = PR(4)
1300 IF PR(5) = 0 THEN 1360
1310 ROT= 0
1320 RA = (280 -((LL +3) *6 +20))/2: IF RA >88 THEN RA = 88: REM RADIUS
1330 XC = RA +4:YC = RA +12
1340 XW = 2 *RA +12:YW = (192 -(NF *7))/2
1350 GOTO 1400
1360 RA = (280 -((NG +4) *7))/2: IF RA >92 THEN RA = 92: REM RADIUS
1370 ROT= 48
1380 XC = RA +13:YC = 96
1390 XW = RA *2 +12:YW = (192 +((LL +4) *6))/2
1400 HGR2 : HCOLOR= 3: HPLOT 0,0 TO 279,0 TO 279,191 TO 0,191 TO 0,0: SCALE= 1
1410 RA = RA +1: HPLOT FN X(0), FN Y(0)
1420 FOR CD = 0 TO 2 *PI STEP .04: HPLOT TO FN X(CD), FN Y(CD): NEXT :RA = RA -1
1430 C1 = PR(6) *2 *PI/360
1440 FOR NS = 1 TO NG
1450 C2 = C1 +V(NS) *2 *PI/TV
1460 ON PR(4) +1 GOSUB 3000,2900
1470 C1 = C2
1480 NEXT
1490 PR(4) = CO
1500 W$ = LE$(PR(2)): IF PR(5) = 0 THEN X = 3:Y = (192 +( LEN(W$) *6))/2: GOSUB 9000: GOTO 1520
1510 X = (280 -( LEN(W$) *6))/2:Y = 3: GOSUB 9000
1520 HOME : GET A$
1530 TEXT : VTAB 1: PRINT "PIE CHART COMPLETED"
1540 PRINT : PRINT " 1. RETURN TO MENU"
1550 PRINT " 2. SEE CHART"
1560 PRINT " 3. RESET PARAMETERS"
1570 VTAB 7: HTAB 1: PRINT "WHAT NOW? ";: CALL -868: GET A$:A = VAL(A$)
1573 IF A <1 OR A >3 THEN 1570
1575 PRINT A$;
1577 GET A$: IF A$ = CHR$(8) THEN 1570
1580 IF A$ < > CHR$(13) THEN 1577
1590 ON A GOTO 2400,1600,140
1600 POKE -16304,0: POKE -16299,0: GOTO 1520
2400 REM RETURN TO MENU
2410 HOME : VTAB 10: PRINT "INSERT PROGRAM DISK IN DRIVE 1": PRINT "AND HIT ANY KEY. USE ESCAPE TO ABORT.";: GET A$
2415 IF A$ = CHR$(27) THEN 140
2420 PRINT : PRINT CHR$(4);"RUN MENU,D1"
2500 REM READ WORD
2510 PL = DL +40 *(VF +1) +8 *(HF -1) -1
2520 WL = 0:W$ = ""
2530 FOR LOC = 8 TO 1 STEP -1
2540 IF PEEK(PL +LOC) >32 THEN WL = LOC:LOC = 1
2550 NEXT LOC
2560 IF WL = 0 THEN RETURN
2570 FOR LOC = 1 TO WL
2580 W$ = W$ + CHR$( PEEK(PL +LOC))
2590 NEXT LOC
2600 RETURN
2700 REM LABEL ROUTINE
2710 W$ = "- " +L$(NS)
2720 IF PR(5) = 1 THEN 2780
2730 REM SIDEWAYS
2740 XW = XW +7:X = XW:Y = YW -12: GOSUB 9000
2750 IF PR(4) = 0 THEN 2840
2760 HCOLOR= CN: FOR Y = YW -2 TO YW +3: HPLOT XW,Y TO XW +4,Y: NEXT Y
2770 GOTO 2850
2780 REM UPRIGHT
2790 YW = YW +7:X = XW +12:Y = YW: GOSUB 9000
2800 IF PR(4) = 0 THEN 2840
2810 HCOLOR= CN: FOR X = XW -3 TO XW +2: HPLOT X,YW TO X,YW +5: NEXT X
2820 HCOLOR= INT(CN/5) *4 +3: HPLOT XW -3,YW TO XW +2,YW TO XW +2,YW +5 TO XW -3,YW +5 TO XW -3,YW
2830 GOTO 2850
2840 DRAW CN +22 AT XW,YW
2850 RETURN
2900 REM COLOR SLICE ROUTINE
2910 CN = CN +1: IF CN = 4 THEN CN = 5
2920 IF CN = 7 THEN PR(4) = 0:CN = 1: GOTO 3020
2930 HCOLOR= CN
2940 FOR CD = C1 TO C2 STEP .01
2950 HPLOT XC,YC TO FN X(CD), FN Y(CD)
2960 NEXT
2970 HCOLOR= INT(CN/5) *4 +3: HPLOT FN X(C1), FN Y(C1) TO XC,YC TO FN X(C2), FN Y(C2)
2980 GOSUB 2700
2990 RETURN
3000 REM B&W SLICE ROUTINE
3010 CN = CN +1
3020 HCOLOR= 3
3030 HPLOT XC,YC TO FN X(C2), FN Y(C2)
3040 RA = RA *.7: DRAW CN +22 AT FN X((C1 +C2)/2), FN Y((C1 +C2)/2):RA = RA/.7
3050 GOSUB 2700
3060 RETURN
9000 REM HGR PRINT
9010 C = 6: IF D >2 THEN C = -6
9020 ROT= 16 *(D +F +1)
9030 FOR CT = 1 TO LEN(W$)
9040 L = ASC( MID$ (W$,CT,1))
9050 IF 64 <L AND L <91 THEN SH = L -42: GOTO 9160
9060 IF L >48 AND L <58 THEN SH = L -37: GOTO 9160
9070 IF L = 32 THEN 9170
9080 IF L >39 AND L <48 THEN SH = L -36: GOTO 9160
9090 IF L = 48 THEN SH = 37: GOTO 9160
9100 IF L >34 AND L <38 THEN SH = L -34: GOTO 9160
9110 IF L = 61 THEN SH = 21: GOTO 9160
9120 IF L = 63 THEN SH = 22: GOTO 9160
9130 IF L = 94 THEN SH = 49: GOTO 9160
9140 PRINT "ERR- NO SHAPE FOR CHARACTER: "; CHR$(L); CHR$(7)
9150 GOTO 9170
9160 DRAW SH AT X,Y
9170 IF D/2 < > INT(D/2) THEN X = X +C: GOTO 9190
9180 IF D/2 = INT(D/2) THEN Y = Y +C
9190 NEXT CT
9200 RETURN